{% extends 'releases/base.html' %}
{% block titel %}发布管理系统-只发布页{% endblock %}
{% block link %}
    <link rel="stylesheet" href="/static/releases/css/onlyfabu.css" type="text/css" media="screen" />
    <link href="/static/releases/css/lib/bootstrap.datepicker.css" type="text/css" rel="stylesheet" />
    <link href="/static/releases/css/lib/select2.css" type="text/css" rel="stylesheet" />
    <link href="/static/releases/css/lib/bootstrap-wysihtml5.css" type="text/css" rel="stylesheet" />
    <link href="/static/releases/css/lib/uniform.default.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="/static/css/compiled/form-showcase.css" type="text/css" media="screen" />
{% endblock %}

{% block body %}
    {% csrf_token %}
<!-- main container -->
    <div class="content">
    	<div id="jinggao" class="alert alert-danger alert-dismissible" role="alert">
		  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only"></span></button>
		  <strong>警告!</strong> 请慎重操作！操作前请先配置Jenkins配置项，发布前请先操作LVS上下线！ 发布完成后请手动绑定hosts。
		</div>
        <!-- upper main stats -->
        <div id="form-only">
	        	<textarea id="textrarval" class="form-control" rows="3" name="fname" placeholder="请输入要发布的项目名，以,分隔！如cps,acps,console"></textarea>
			  <button id="onlyfabu" type="button" class="btn btn-info btn-lg" onclick="fbajax(this,3);">开始发布</button>
        </div>
		<div class="xianshiqi">
				<pre id="xianshi">正在初始化中。。。</pre>
		</div>

    </div>
{% endblock %}

{% block javascript %}
    <script src="/static/releases/js/jquery.cookie.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var $canshu=$('#onlymo');
            var $span=$('<div class="pointer"> <div class="arrow"></div> <div class="arrow_border"></div> </div>');
            $($canshu).append($span);
            $($canshu).addClass("active");
            $('#onlyrele').addClass("active");
            $('#onlyrele2').addClass("active");
    })
    </script>
    <script>
        function fbajax(doc,id) {
            if (document.getElementById('textrarval').value=='')
            {
                $("#textrarval").addClass('redxsq');
                $("#textrarval").attr('placeholder','不得为空!!!  请输入要发布的项目名，以,分隔！如cps,acps,console')
                return false;
            }
            $("#xianshi").text('正在执行中，请等待。。。。');
            $("#textrarval").removeClass('redxsq');
            var vals = $('#textrarval').val();
            $.ajax({
                url:'/onrelease/',
                type:'POST',
                data:{modify:id,date:vals},
                success:function (arg) {
                    var obj = jQuery.parseJSON(arg);
                    var this_id = $(doc).attr('id');
                    console.log(this_id);
                    $('#'+this_id).attr("disabled","disabled");
                    $("#xianshi").removeClass('redxsq');
                    $("#xianshi").text(obj.data);
                    console.log(obj.msg);
                },
                error:function () {
                    $("#xianshi").text('请求失败！');
                    $("#xianshi").addClass('redxsq');
                    console.log(obj.msg);
                }
            });
        }
    </script>
    <script>
        var csrftoken = $.cookie('csrftoken');
        function csrfSafeMethod(method) {
            // these HTTP methods do not require CSRF protection
            return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
        }
        $.ajaxSetup({
            beforeSend: function(xhr, settings) {
                if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                    xhr.setRequestHeader("X-CSRFToken", csrftoken);
                }
            }
        });
    </script>
    <script type="text/javascript">

		$(document).ready(function(){

			$("#xianshi").text("初始化完成，开始发布吧！！");
		});
    </script>
{% endblock %}